# -*- coding: utf-8 -*-
from Crypto.Cipher import AES
import base64
PADDING = '\0'
pad_it = lambda s: s+(16 - len(s)%16)*PADDING
key = '1234567812343999'
iv = '1234567812343123'

def aes_encrypt_str(source):
    generator = AES.new(key, AES.MODE_CBC, iv)
    crypt = generator.encrypt(pad_it(source.encode('utf-8')))
    return base64.b64encode(crypt)


def aes_decrypt(cryptedStr):
    crypt = base64.b64decode(cryptedStr)
    generator = AES.new(key, AES.MODE_CBC, iv)
    recovery = generator.decrypt(crypt)
    return recovery.rstrip(PADDING)

if __name__ == '__main__':
    # source = "423423312312312"
    # lR9Gnu3E7qvk3a71oN6DAA ==
    # t =  aes_encrypt_str(source)
    print aes_decrypt('9idzQybZxU04J72NOO9G/pqppd3L2PkiQCW7HJ5FN7k=')
    print aes_decrypt('uZkx4ExJ4V+k9UDCHonctQ==')